Skip to content

Chat Agent bugfix to treat workspace file references and attachments separately - #2717

Merged
GeorgeNgMsft merged 9 commits into
mainfrom
dev/georgeng/fix_chat_file_bug
Aug 4, 2026
Merged

Chat Agent bugfix to treat workspace file references and attachments separately#2717
GeorgeNgMsft merged 9 commits into
mainfrom
dev/georgeng/fix_chat_file_bug

Conversation

@GeorgeNgMsft

@GeorgeNgMsft GeorgeNgMsft commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fix chat agent crash on highlighted editor files

Problem

When a user highlights lines in an editor (no upload) and asks a question, the
dispatcher's [Editor context] carries the workspace-relative file path, and the
LLM puts it into chat.generateResponse.relatedFiles. The chat agent assumed
every related file was an uploaded attachment staged under the session's
user_files/, joined the name there, and sessionStorage.read threw ENOENT —
failing the entire response. It also tried to embed every related file as an
image and only handled Windows path separators.

Fix

  • New shared helper rehydrateImageAttachments in typechat-utils (used by
    both chat and dispatcher/search, replacing two near-identical copies). It
    gates on image MIME before any storage read, so a highlighted .yml is
    skipped with zero I/O — no read, no crash. Missing image uploads are caught and
    skipped. Also fixes a latent doubled-image/ data-URL bug and makes the
    user_files lookup portable via path.join (the old \..\user_files\ only
    resolved on Windows).
  • Correct entity typing (relatedFileToEntity): uploaded images →
    ["file","image","data"]; other references → ["file"] (was hardcoded to
    image for everything).
  • Schema nudge: tightened the relatedFiles comment so the model only lists
    uploaded attachment names, not editor/workspace files.
image

@GeorgeNgMsft GeorgeNgMsft reopened this Jul 21, 2026
@GeorgeNgMsft GeorgeNgMsft changed the title Chat Agent bugfix for file path resolution Chat Agent bugfix to treat workspace file references and attachments separately Jul 21, 2026
GeorgeNgMsft and others added 3 commits August 3, 2026 16:58
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 475784cc-a88f-4fae-ab22-4b5b562b7ff3
The pull's text-merge of pnpm-lock.yaml dropped the root esbuild@0.28.1
dependency that main added in #2785, so pnpm install --frozen-lockfile
(the CI default) failed with ERR_PNPM_OUTDATED_LOCKFILE. Regenerated the
lockfile with pnpm 11.9.0 so it matches the merged package.json manifests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 475784cc-a88f-4fae-ab22-4b5b562b7ff3
@GeorgeNgMsft
GeorgeNgMsft marked this pull request as ready for review August 4, 2026 00:08
@GeorgeNgMsft
GeorgeNgMsft enabled auto-merge August 4, 2026 00:10
@GeorgeNgMsft
GeorgeNgMsft disabled auto-merge August 4, 2026 03:06
@GeorgeNgMsft
GeorgeNgMsft enabled auto-merge August 4, 2026 04:51
@GeorgeNgMsft
GeorgeNgMsft added this pull request to the merge queue Aug 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 4, 2026
@GeorgeNgMsft
GeorgeNgMsft added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit 0971ec4 Aug 4, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants